/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package utils;

import org.json.JSONObject;

/**
 *
 * @author banhbaochay
 */
public class Media {

    public Media(JSONObject media) {
        this.media = media;
        _attribs = media.optJSONObject("_attribs");
    }

    /**
     * Get titlte of a media
     * @return null if error
     */
    public String getTitle() {
        return media.optString("title", null);
    }// end getTitle method

    /**
     * Get url of a media
     * @return null if error
     */
    public String getURL() {
        return media.optString("url", null);
    }// end getTitle method

    /**
     * Get name of a media
     * @return null if error
     */
    public String getName() {
        if (_attribs != null) {
            return _attribs.optString("name", null);
        } else {
            return null;
        }// end if _attribs != null
    }// end getTitle method

    /**
     * Get username who upload media
     * @return null if error
     */
    public String getUsername() {
        if (_attribs != null) {
            return _attribs.optString("username", null);
        } else {
            return null;
        }// end if _attribs != null
    }// end getTitle method

    /**
     * Get type of a media
     * @return null if error
     */
    public String getType() {
        if (_attribs != null) {
            return _attribs.optString("type", null);
        } else {
            return null;
        }// end if _attribs != null
    }// end getTitle method 
    /*
     * Private member
     */
    private JSONObject media;
    private JSONObject _attribs;
}// end Media class

